﻿Imports System.Data.OleDb
Imports System.Web.HttpUtility

Public Class AquariumRSS
    Inherits ItemRSSPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("fishTankConnection").ConnectionString)
        oleDbConn.Open()
        rssRepeaterDataBind(oleDbConn)
        oleDbConn.Close()
    End Sub

    Private Sub rssRepeaterDataBind(oleDbConn As System.Data.OleDb.OleDbConnection)
        Dim SqlString As String = "SELECT [ID], [Title], [Description], [MemberFullName], [CreatedDateTime] FROM AquariumListView ORDER BY CreatedDateTime DESC"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        Dim dataReader = cmd.ExecuteReader()
        aquariumRSS.DataSource = dataReader
        aquariumRSS.DataBind()
    End Sub

    Protected Function encodeHTML(text As String) As String
        Dim encoded As String
        encoded = HttpUtility.HtmlEncode(text)
        Return encoded
    End Function

    Protected Function getLeftPartURL() As String
        Return HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)
    End Function
End Class